Module ReserveCarRecompense
    Function Select_InvReserveCarRecompense(ByVal ReserveCarRecompenseId As String, ByVal UserId As String, ByVal UnitId As String, _
    ByVal CarId As String, ByVal TypeCloseJob As String, ByVal TypeReseve As String, ByVal bUssinessUnit As String, _
    ByVal DateRepairStart As String, ByVal DateRepairStop As String) As DataSet
        Call Set_IP_Address_WebService()
        Dim DsReserveCarRecompense As New DataSet
        Try
            DsReserveCarRecompense = pTt_PIS.Select_InvCarRecompense(ReserveCarRecompenseId, UserId, _
                   UnitId, CarId, TypeCloseJob, TypeReseve, bUssinessUnit, DateRepairStart, DateRepairStop)
            If Not DsReserveCarRecompense Is Nothing Then
                Dim ii As Integer
                Dim iCount As Integer = DsReserveCarRecompense.Tables(0).Rows.Count - 1
                For ii = 0 To iCount
                    Dim EmpCode As String = DsReserveCarRecompense.Tables(0).Rows(ii).Item("CarRecompenseUserId")
                    Dim dS As DataSet = pTt_PIS.GetInformationEmployee(EmpCode, "")
                    Try
                        DsReserveCarRecompense.Tables(0).Rows(ii).Item("CarRecompenseUserName") = CStr(dS.Tables(0).Rows(0).Item("EmpName")) '& "<br>" & CStr(dS.Tables(0).Rows(0).Item("posname"))
                        DsReserveCarRecompense.Tables(0).Rows(ii).Item("CarRecompenseUnitName") = CStr(dS.Tables(0).Rows(0).Item("unitabbr"))
                    Catch ex As Exception
                        DsReserveCarRecompense.Tables(0).Rows(ii).Item("CarRecompenseUserName") = EmpCode
                    End Try

                    DsReserveCarRecompense.Tables(0).Rows(ii).Item("CarRecompenseDate") = Set_Format_Date(DsReserveCarRecompense.Tables(0).Rows(ii).Item("CarRecompenseDate"))
                    DsReserveCarRecompense.Tables(0).Rows(ii).Item("CarRecompenseSendDateRepair") = Set_Format_Date(DsReserveCarRecompense.Tables(0).Rows(ii).Item("CarRecompenseSendDateRepair"))
                    DsReserveCarRecompense.Tables(0).Rows(ii).Item("CarRecompenseCompleteDateRepair") = Set_Format_Date(DsReserveCarRecompense.Tables(0).Rows(ii).Item("CarRecompenseCompleteDateRepair"))
                    DsReserveCarRecompense.Tables(0).Rows(ii).Item("CarRecompenseDistributeDate") = Set_Format_Date(DsReserveCarRecompense.Tables(0).Rows(ii).Item("CarRecompenseDistributeDate"))
                    DsReserveCarRecompense.Tables(0).Rows(ii).Item("CarRecompenseReturnDateRepair") = Set_Format_Date(DsReserveCarRecompense.Tables(0).Rows(ii).Item("CarRecompenseReturnDateRepair"))
                    DsReserveCarRecompense.Tables(0).Rows(ii).Item("CarRecompensePayDateCar") = Set_Format_Date(DsReserveCarRecompense.Tables(0).Rows(ii).Item("CarRecompensePayDateCar"))
                Next
                DsReserveCarRecompense.Tables(0).AcceptChanges()
                Select_InvReserveCarRecompense = DsReserveCarRecompense
            Else
                Select_InvReserveCarRecompense = Nothing
            End If
        Catch ex As Exception

            Select_InvReserveCarRecompense = Nothing
        End Try


    End Function

    Function Set_Format_Date(ByVal xDate As String) As String
        Try
            Dim tMpDate As String = Split(xDate, " ")(0).ToString

            Set_Format_Date = Split(tMpDate, "-")(2) & "-" & Split(tMpDate, "-")(1) & "-" & GetYear2(CStr(Split(tMpDate, "-")(0)))


        Catch ex As Exception
            Set_Format_Date = ""
        End Try

    End Function

End Module
